package com.mryin.performance.config;

import com.google.common.base.Predicates;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @program: MRYIN-ERP
 * @description: Swagger2Configpeizhiwenjian
 * @author: Mr.YIN
 * @create: 2021-02-25 16:09
 **/

/**
 *  fanwen http://localhost:9966/swagger-ui.html
 */
@EnableSwagger2
@Configuration
public class Swagger2Config {
    @Value("true")
    private Boolean enable;
    @Bean
    public Docket webApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("MRYIN-Api")
                .apiInfo(webApiInfo())
                .enable(enable) // 是否显示
                .select()
                .paths(Predicates.not(PathSelectors.regex("/error.*")))
                .build();
    }

    private ApiInfo webApiInfo(){
        return new ApiInfoBuilder()
                .title("MRYIN-Api")
                .description("MRYIN-ERP-Api")
                .version("1.0")
                .contact(new Contact("MRYIN", "https://mail.qq.com/cgi-bin/frame_html?sid=1Unb0Aj4z52rZAlp&r=2aa4f6094c6f4edadc5da166c0dd0a47", "1834145948@qq.com"))
                .build();
    }

}
